#!/usr/bin/python3
# -*- coding:utf-8 -*-
"""
@author: 蒋艰坚
@file: main.py
@time: 2021/7/7 9:49
@desc: 
"""

import os

from Face_Num.My_Count import Face_Num
from Word_OCR.MY_OCR import My_OCR
from animal_classify import animal_classify


def rename():
    file_path = ""
    file_dict = {}
    kind_dict = {}
    with open("the_file.txt", 'r', encoding='utf-8') as f:
        file_path = f.readline()
    dir_list = os.listdir(file_path)
    for file in dir_list:
        results = Face_Num(file_path + '/' + file)
        data = My_OCR(file_path + '/' + file)
        kind = animal_classify(file_path + '/' + file)
        name = str(len(results[0]['data']))
        for infomation in data:
            name += "_" + infomation['text']
        file_name = name + ".jpeg"
        file_dict[file_path + '/' + file] = file_name
        for str1 in kind:
            if '犬' in kind or '狗' in str1:
                kind_dict[file_path + '/' + file] = '狗'
                break
            elif '猫' in str1:
                kind_dict[file_path + '/' + file] = '猫'
                break
            elif '兔' in str1:
                kind_dict[file_path + '/' + file] = '兔子'
                break
            elif '龟' in str1:
                kind_dict[file_path + '/' + file] = '乌龟'
                break
            elif '鱼' in str1:
                kind_dict[file_path + '/' + file] = '鱼'
                break
            elif '鸟' in str1:
                kind_dict[file_path + '/' + file] = '鸟'
                break
            else:
                kind_dict[file_path + '/' + file] = None
    return file_dict, kind_dict


if __name__ == '__main__':
    file_dict, kind_dict = rename()
    print(file_dict)
    print(kind_dict)
